﻿using System;
using System.Collections.Generic;
using System.Web;
using ArkEC.CoreCom.WebHandler;

namespace ArkEC.SEMs.WebUI.BZM
{
    /// <summary>
    /// Ajax的Web请求处理
    /// </summary>
    public class BizAjaxHandler : IHttpHandler
    {
        /// <summary>
        /// 处理请求
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            string responseStr = "";
            try
            {
                responseStr = BizHandler.HandlerRequest(context);
            }
            catch (Exception err)
            {
                responseStr = "{ Error: \"" + err.Source + "\", Message: \"" + err.Message + "\" }";

                /* 文件上传动作 */
                if (context.Request.Files.Count > 0)
                {
                    context.Response.Cookies.Add(new HttpCookie("Response", responseStr));
                }
            }

            context.Response.Write(responseStr);
        }

        /// <summary>
        /// 
        /// </summary>
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}